<!DOCTYPE HTML>
<title>SVGNumber interface</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
test(function() {
  // This test checks the SVGNumber API.

  var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
  var num = svgElement.createSVGNumber();

  // Check initial number value.
  assert_equals(num.value, 0);

  // Check assigning number.
  num.value = 100;
  assert_equals(num.value, 100);
  num.value = -100;
  assert_equals(num.value, -100);
  num.value = 12345678;
  assert_equals(num.value, 12345678);
  num.value = -num.value;
  assert_equals(num.value, -12345678);

  // Check that numbers are static, caching value in a local variable and modifying it, should have no effect.
  var numRef = num.value;
  numRef = 1000;
  assert_equals(numRef, 1000);
  assert_equals(num.value, -12345678);

  // Check assigning invalid number, number should be 0 afterwards.
  num.value = 0;
  assert_equals(num.value, 0);
  assert_throws_js(TypeError, function() { num.value = num; });
  assert_throws_js(TypeError, function() { num.value = 'aString'; });
  assert_throws_js(TypeError, function() { num.value = svgElement; });
  assert_throws_js(TypeError, function() { num.value = NaN; });
  assert_throws_js(TypeError, function() { num.value = Infinity; });
  assert_equals(num.value, 0);
  num.value = null;
  // Check that the number is now null.
  assert_equals(num.value, 0);
});
</script>